# -*- coding:utf-8 -*-
#Python
#Generator: PyCharm
#Author: Zhong
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'


import sys
sys.path.pop(0)
sys.path.insert(0, 'f:\\emps\\emps')


from django.db import transaction
from emp.manager import saveEmp,showAll

@transaction.commit_on_success
def testGetEmp():
    vals = u'分公司领导    =1,经理,千    仲,2058,8263422,15141559988,6666,,'
    employee = vals.split('=')
    #print  emp[0],'=',len(emp[1].split(',')),'=',vals
    saveEmp(employee[0],employee[1].split(','))

#testGetEmp()

from emp import models

def changeTypeOrder():
    objs = models.Category.objects.all()
    for obj in objs:
        obj.order = obj.id
        obj.save()

def changeDepOrder():
    objs = models.Department.objects.all()
    for obj in objs:
        obj.order = obj.id
        obj.save()

#changeTypeOrder()
#changeDepOrder()

#models.Department.objects.get(name='分公司领导').category =  []
#models.Category.objects.get(name='管理').department_set.values()

from django.template.loader import get_template
from django.template import Context
def testShow():
    html = get_template('emp/build.html').render(Context({'cates': showAll(), 'isDownload': True}))
    print html.encode('utf-8')
    open('./out.html','w').write(html.encode('utf-8'))


testShow()

#deps = models.Department.objects.all()
#for dep in deps:
#    dep.employee_set.clear()

#for emp in models.Employee.objects.all():
    #emp.delete()